// FILE: Chip8Keyboard.cpp by Richard Hughes 03/05/2012
//
// DESC: Implements the Chip8 Keyboard

// INCLUDES
#include "Chip8Keyboard.h"

// NAMESPACES
using namespace std;

namespace Emulator
{
namespace Chip8
{

/*************************************************************/
//
// CLASS: Chip8Keyboard
//
// DESC: The Chip 8 Keyboard definition
//
/*************************************************************/

// hangs in an infinate loop until a key is pressed
// takes nothing
// returns nothing
Chip8Key Chip8Keyboard::WaitUntilKeyPress()
{
	Chip8Key key = Chip8Key_0;

	while(true)
	{
		if(this->IsKeyDown(Chip8Key_0))
		{
			key = Chip8Key_0;
			break;
		}
		if(this->IsKeyDown(Chip8Key_1))
		{
			key = Chip8Key_0;
			break;
		}
		if(this->IsKeyDown(Chip8Key_2))
		{
			key = Chip8Key_2;
			break;
		}
		if(this->IsKeyDown(Chip8Key_3))
		{
			key = Chip8Key_3;
			break;
		}
		if(this->IsKeyDown(Chip8Key_4))
		{
			key = Chip8Key_4;
			break;
		}
		if(this->IsKeyDown(Chip8Key_5))
		{
			key = Chip8Key_5;
			break;
		}
		if(this->IsKeyDown(Chip8Key_6))
		{
			key = Chip8Key_6;
			break;
		}
		if(this->IsKeyDown(Chip8Key_7))
		{
			key = Chip8Key_7;
			break;
		}
		if(this->IsKeyDown(Chip8Key_8))
		{
			key = Chip8Key_8;
			break;
		}
		if(this->IsKeyDown(Chip8Key_9))
		{
			key = Chip8Key_9;
			break;
		}
		if(this->IsKeyDown(Chip8Key_A))
		{
			key = Chip8Key_A;
			break;
		}
		if(this->IsKeyDown(Chip8Key_B))
		{
			key = Chip8Key_B;
			break;
		}
		if(this->IsKeyDown(Chip8Key_C))
		{
			key = Chip8Key_C;
			break;
		}
		if(this->IsKeyDown(Chip8Key_D))
		{
			key = Chip8Key_D;
			break;
		}
		if(this->IsKeyDown(Chip8Key_E))
		{
			key = Chip8Key_E;
			break;
		}
		if(this->IsKeyDown(Chip8Key_F))
		{
			key = Chip8Key_F;
			break;
		}
	} // end while

	return key;
} // end WaitUntilKeyPress

} // end namespace Chip8
} // end namespace Emulator

// EOF: Chip8ROM.cpp